package PAT;

import java.util.Scanner;
import java.util.Stack;


/**
 * 分析：按照要求进行模拟。先把输入的序列接收进数组v。然后按顺序1~n把数字进栈，每进入一个数字，
 * 判断有没有超过最大范围，超过了就break。如果没超过，设current = 1，从数组的第一个数字开始，
 * 看看是否与栈顶元素相等，while相等就一直弹出栈，不相等就继续按顺序把数字压入栈～～最后根据
 * 变量flag的bool值输出yes或者no～
 */
public class PAT1051 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        while (c-->0){
            int[] ints = new int[b];
            for (int i = 0; i < b; i++) {
                ints[i] = scanner.nextInt();
            }
            judge(ints,a,b);

        }
    }

    private static void judge(int[] ints, int a, int b) {
        int index = 1;
        Stack<Integer> stack = new Stack<>();
        for (int i = 1; i <=b; i++) {
            stack.push(i);
            if(stack.size()>a)break;
            while (!stack.isEmpty() && stack.peek() == ints[index-1]){
                stack.pop();
                index++;
            }
        }
        if(index ==b+1){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }

}
